< previous page page_504 next page >

Page 504
Overview
Before jumping into the tools and techniques of debugging your application, it is a good idea to understand what bugs are and how a user would see a bug. In addition, the differences between testing and debugging and how they are tightly related will be explained.
Someone once said that testing is a never-ending process, or to put it another way, there will always be one more bug. But, what are bugs? How do we find them and then fix them? Back when computers took up whole rooms and used hot vacuum tubes, finding bugs was really quite simple. All you had to do was walk into the computer and remove the dead bugs that were preventing the computer's physical switches from closing. Thus, the term debugging was born. Unfortunately, it isn't that simple anymore.
The process is much more complicated, both in terms of what is considered a bug and how bugs are found. A programmer must now test and then debug his application code using time, logic, and the tools that are available from the development system. But, what is testing and what is debugging? Testing is the process by which applications are put through every possible keystroke, mouse click, and input; these test cases hopefully exercise every line of code in the application. It is during this process that any indication of an application error should be located. After a problem is found, the debugging process starts. Debugging is a multi-part process that determines the problem and its location in the code, and then fixes it. When the problem has been fixed, you must go back and rerun the test that caused the error to see if you really fixed it. If the problem has been resolved, you can move on to the next test.
Bugs can mean different things to different people. They range from the annoying (misspellings) to the serious (Windows terminates) to the deadly (load data). To the user of your application, a bug is anything that doesn't conform to her expected results. But, to a programmer, a bug is something that produces unexpected results or prevents the application from executing. Now these two definitions might sound similar, but if you take a closer look, you would find that they are very different. If an application is executing properly but doesn't perform the tasks or actions that were initially required of it, the user could consider it a bug. However, the programmer would say that it is performing as designed. So, to a user, a bug is anything unexpected (even bad answers, as opposed to incorrect answers), whereas the programmer would define a bug as a mistake in the technical design and execution of the application.
When testing and debugging your application, you will face many problems that relate to finding and fixing the bugs. Although this will sound a little trite, the best way to debug the application is to take the time to carefully plan and design the application before you begin coding. Beyond that, you should create a physical list of the tests you want to perform on the application during the testing and debugging process. This will prevent you

 
< previous page page_504 next page >

If you like this book, buy it!